﻿@{
    var X = Html.X();
}

@(X.Panel()     
      .Layout(LayoutType.HBox)
      .Border(false)
      .BodyStyle("background-color:lightcyan")
      .Items(
          X.Panel().Border(false).Flex(1)
              .BodyStyle("background-color:lightcyan;font-size:30px")
              .Height(50)
              .Layout(LayoutType.HBox)
              .LayoutConfig(new HBoxLayoutConfig { Align = HBoxAlign.Middle,Pack = BoxPack.Start})
              .Items(
                      X.Label().Text("业务管理系统").Height(50)
                      .ID("SysLogo")             
                      .PaddingSpec("0 0 0 20")
              ),
          X.Panel().Border(false).Flex(1)                             
              .Items(
                  X.Panel().Region(Region.Center)
                      .BodyStyle("background-color:lightcyan")
                      .Height(20)
                      .Border(false),
                  X.Panel().Region(Region.South)
                      .BodyStyle("background-color:lightcyan")
                      .Height(30)
                      .MarginSpec("0 0 8 0")                     
                      .Border(false)
                      .Layout(LayoutType.HBox)
                      .LayoutConfig(new HBoxLayoutConfig{ Align = HBoxAlign.Middle,Pack = BoxPack.End})
                      .Items(                          
                          X.HyperlinkButton()
                              .Text("修改密码")
                              .PaddingSpec("0 10 0 0")
                              .Handler("App.WinModCurrentPassword.show();")
                              .ID("UserModPassword"),
                          X.HyperlinkButton()
                              .Text("退出")
                              .OnClientClick("logout")
                              .PaddingSpec("0 10 0 0")
                              .ID("SysLogout"),
                          X.Label().Text("您好！"),
                          X.Label().Text(ViewData["userNickName"].ToString())
                              .PaddingSpec("0 10 0 0"),
                          X.Label().Text("当前时间:"),
                            
                          X.Label()
                              .ID("CurrentTime")                              
                              .Text(ViewData["Timer"].ToString())
                              .PaddingSpec("0 10 0 0")
                      )
              )
      ))

<script>
    function setTimeValue() {
        var vT = $("#CurrentTime").text();

        if (vT != undefined) {
            var vDate = new Date(vT.replace(/-/g, "/"));
            vDate.setSeconds(vDate.getSeconds() + 1);

            $("#CurrentTime").text(vDate.format("yyyy-MM-dd hh:mm:ss"));
        }
    }

    Date.prototype.format = function (format) {
        var o = {
            "M+": this.getMonth() + 1, //month
            "d+": this.getDate(), //day
            "h+": this.getHours(), //hour
            "m+": this.getMinutes(), //minute
            "s+": this.getSeconds(), //second
            "q+": Math.floor((this.getMonth() + 3) / 3), //quarter
            "S": this.getMilliseconds() //millisecond
        }

        if (/(y+)/.test(format)) {
            format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        }

        for (var k in o) {
            if (new RegExp("(" + k + ")").test(format)) {
                format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
            }
        }
        return format;
    }

    var setT = null;
    $(function () {
        setT = window.setInterval(setTimeValue, 1000);

    });

    function logout() {
        $.post("Logout", {}, function (data) {
            if (data.Result == "OK") {
                window.location = "/";
            }
        });
    }
</script>